package com.goldsprite.microhorigame.ecs.fsms.states;

public class EntityMoveState extends EntityState {
		private int lastFacing;

		@Override
		public boolean canEnter() {
			return fsm.getInputs().isMoving();
		}

		@Override
		public boolean canExit() {
			return !fsm.getInputs().isMoving();
		}

		@Override
		public void enter() {
			lastFacing = fsm.getProps().getFacing();
			fsm.getAnims().playAnim("Move", true);
		}

		@Override
		public void running() {
			if(fsm.getProps().getFacing() != lastFacing){
				fsm.getAnims().playAnim("Move", true);
				lastFacing = fsm.getProps().getFacing();
			}

			fsm.getProps().setSpeedBoost(fsm.getInputs().getKeySpeedBoost());
			fsm.getProps().move(fsm.getInputs().getKeyDirX());
		}
	}
